/**
 * 选择商品种类联动
 * @param obj
 */
function selectGoodsType(obj){
	var goodsClassificationId = $(obj).val();
	$.ajax({
		   type: "POST",
		   url: "purchaseItemAction/selectShangPin.action",
		   data: {goodsClassificationId:goodsClassificationId},
		   success: function(html){
		     $("#caigouGoods").html(html);
		   }
		   
		});
	
}
/**
 * 打印验收单
 */
function toPrintYanshou(obj){
	$(obj).parent().remove();
	$("#toPrintYanshou").printArea();
}

/**
 * 打印供货合同
 */
function previewContract(obj){
	$(obj).parent().remove();
	$("#box").printArea();	
	
}
/**
 * 打印采购办合同
 */
function cgspreviewContract(obj){
	$(obj).parent().remove();
	$("#box").printArea();
}
/**
 * 打印采购合同
*/	
function findpreviewContract(obj){
	$(obj).parent().remove();
	$("#box").printArea();
}
/**
 * 安宁财政局查看合同
*/	

function findprintYanshou(obj){
	$(obj).parent().remove();
	$("#printYanshou").printArea();
}



/**
 * 打印申报表
 */
function printAppoveing(obj){
	$(obj).parent().remove();
	$("#printAppoveing").printArea();
}

function printApproved(obj){
	$(obj).parent().remove();
	$("#giveapprove").printArea();
	
}






function testConfirmMsg(url, data){
	alertMsg.confirm("确认提交？", {
		okCall: function(){
			$.post(url, data, DWZ.ajaxDone, "json");
		}
	});
}

//检索采购单位
function unitsSerach(){
	var unitsName = $("#unitsSerach").val();
	$("#searchBJD").attr("href","offerAction/getUnitsListSearch.action?unitsName="+unitsName);
	$("#searchBJD").click();
	$("#searchBJD").attr("href","offerAction/getUnitsList.action");
}

function searchUnits(){
	var unitsName = $("#unitsSerach").val();
	$("#testid").attr("href","offerAction/getUnitsListSearch.action?unitsName="+unitsName);
}

//检索采购单位
function azcSerach(){
	var unitsName =$("#unitsSerach1").val();
	
	$("#azcPrice").attr("href","offerAction/getAzcListSearch.action?unitsName="+unitsName);
	$("#azcPrice").click();
	$("#azcPrice").attr("href","offerAction/getPurchasingUnit.action");
	/*$.post("offerAction/getUnitsListSearch.action",{unitsName:unitsName}, function(html){
		   $("#unitsAjax").html(html);
		   $("#caigoudanwei").click();
		 });*/
}

$(function(){
	$("#selectBegin").change(function(){
		var begin =parseInt($(this).val());
		var end = $(this).children().length;
		var html ="";
		for(var i=begin;i<=end;i++){
			html+='<option value="'+i+'" >'+i+'</option>';
		}
		$("#selectPage").html(html);
	});
});
//增加空行
function addRow(){
	$("#removeRow").fadeIn();
	$("#nextTr").before("<tr><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td></tr>");
}
//删除行
function removeRow(obj){
	var oTr=$("#nextTr");
	var txt=oTr.prev().children().text();
	if(txt==""){
		$("#nextTr").prev().remove();
		txt=oTr.prev().children().text();
		if(txt!=""){
			$(obj).fadeOut();
		}
	}
	else{
		$(obj).fadeOut();
	}
}

//
var lut_d=0;
function addRow1(){
	var num=parseInt($(".jiafenle").prev("tr").children("td").eq(0).text());
	var next=num+1;
	$("#removeRow").fadeIn();
	$("#btr").before("<tr style='height: 34px;'><td style='border: 1px solid #111;'>"+next+"</td><td class='to_td' style='border: 1px solid #111;'></td><td colspan=5 style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td><td style='border: 1px solid #111;'></td></tr>");
}
//删除行
function removeRow1(obj){
	var oTr=$(".to_td");
	if(oTr){
		$(".jiafenle").prev().remove();
		if(oTr.length==1){
			$(obj).fadeOut();
		}
	}
}

//提交采购办审批通过后向供应商发送短信的请求
function sendMessage(approveId){
	$.ajax({
	   type: "POST",
	   url: "approveAction/sendMessageToSupplier.action",
	   data: {approveId:approveId},
	   dataType: "json",
	   success: function(json){
		   alert(json.message);
	   }
	});
}

//验收单保存验证
/*function validateUnitNumber(){
	if(!/^\d{4}-\d{1,5}$/.test($("[name='unitNumber']").val())){
		$("[name='unitNumber']").parent().append("<span htmlfor='unitNumber_849' generated='true' class='error' style='width:245px;'>只能输入数字和英文横杠，列如：2015-123</span>");
		return false;
	}
	return true;
}

function validateAttribute7(){
	if(!/^\d{4}-\d{1,5}$/.test($("[name='attribute7']").val())){
		$("[name='attribute7']").parent().append("<span htmlfor='attribute7_849' generated='true' class='error' style='width:245px;'>只能输入数字和英文横杠，列如：2015-123</span>");
		return false;
	}
	return true;
}*/
